#-*- coding: utf8 -*-
from tutor.scripts import *
from tutor.plugins.sympy import *

while True:
    # Entradas
    with display_block('Entradas'):
        a = One * oneof(Half, sqrt(2), sqrt(3), Three/2, 2, 3)
        curve_1, is_upper = oneof((sqrt(x), True),
                               (x**2/a, False),
                               (x**4/a**2, False),
                               (a*x**(1/3), False),)
        curve_1 = simplify(curve_1)
        func = Lambda(x, curve_1)
        curve_2 = simplify(func(a)/a * x)
        
    with display_block('Auxiliares'):
        if is_upper:
            upper, lower = curve_1, curve_2
        else: 
            upper, lower = curve_2, curve_1
            
        upper_I = simplify(upper.integrate([x, 0, a]))
        lower_I = simplify(lower.integrate([x, 0, a]))
        
    with display_block('Respostas'):
        correta = upper_I - lower_I
        limiteSuperior = upper_I
        distratores = set([
            correta,
            limiteSuperior,
            lower_I,
            simplify(correta * a),
            simplify(correta / a),
            simplify(upper_I * a),
            simplify(upper_I / a),
            simplify(lower_I * a),
            simplify(lower_I / a),
        ])
        if len(distratores) < 8:
            continue
        distratores.remove(correta)
        distratores.remove(limiteSuperior)
        dis1, dis2, dis3, dis4, dis5, dis6 = list(distratores)[0:6]      
        break
